import SysUserModel from "../../../model/system/SysUserModel";
import SysRoleModel from "../../../model/system/SysRoleModel";

SysUserModel.belongsToMany(SysRoleModel, {
  as: "role", // 目标别名
  through: "sys_user_role", // 关联表名称
  foreignKey: "userId", // 当前模型在关联表中的外键
  otherKey: "roleId", // 对方模型在关联表中的外键
  timestamps: false,
});

SysRoleModel.belongsToMany(SysUserModel, {
  as: "user",
  through: "sys_user_role",
  foreignKey: "roleId",
  otherKey: "userId",
  timestamps: false,
});
